package com.zzyy.study.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.ollama.OllamaChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @auther zzyy
 * @create 2025-02-14 21:15
 */
@RestController
public class OllamaController
{
    @Resource
    private OllamaChatClient ollamaChatClient;

    //http://localhost:8003/ai/ollama
    @GetMapping("/ai/ollama")
    public Map<String, String> completion(@RequestParam(value = "msg", defaultValue = "你是谁") String msg)
    {
        return Map.of("generation", ollamaChatClient.call(msg));
    }
}
